const { Controller } = require('egg');
const regions = [
  {
    id: 1,
    code: 'us',
    name: '美国',
  },
  {
    id: 2,
    code: 'hk',
    name: '香港',
  },
  {
    id: 3,
    code: 'ad',
    name: '安道尔',
  },
  {
    id: 4,
    code: 'ae',
    name: '阿联酋',
  },
  {
    id: 5,
    code: 'af',
    name: '阿富汗',
  },
  {
    id: 6,
    code: 'ag',
    name: '安提瓜和巴布达',
  },
  {
    id: 7,
    code: 'ai',
    name: '安圭拉',
  },
  {
    id: 8,
    code: 'al',
    name: '阿尔巴尼亚',
  },
  {
    id: 9,
    code: 'am',
    name: '亚美尼亚',
  },
  {
    id: 10,
    code: 'ao',
    name: '安哥拉',
  },
  {
    id: 11,
    code: 'aq',
    name: '南极洲',
  },
  {
    id: 12,
    code: 'ar',
    name: '阿根廷',
  },
  {
    id: 13,
    code: 'as',
    name: '美属萨摩亚',
  },
  {
    id: 14,
    code: 'at',
    name: '奥地利',
  },
  {
    id: 15,
    code: 'au',
    name: '澳大利亚',
  },
  {
    id: 16,
    code: 'aw',
    name: '阿鲁巴',
  },
  {
    id: 17,
    code: 'ax',
    name: '奥兰群岛',
  },
  {
    id: 18,
    code: 'az',
    name: '阿塞拜疆',
  },
  {
    id: 19,
    code: 'ba',
    name: '波黑',
  },
  {
    id: 20,
    code: 'bb',
    name: '巴巴多斯',
  },
  {
    id: 21,
    code: 'bd',
    name: '孟加拉',
  },
  {
    id: 22,
    code: 'be',
    name: '比利时',
  },
  {
    id: 23,
    code: 'bf',
    name: '布基纳法索',
  },
  {
    id: 24,
    code: 'bg',
    name: '保加利亚',
  },
  {
    id: 25,
    code: 'bh',
    name: '巴林',
  },
  {
    id: 26,
    code: 'bi',
    name: '布隆迪',
  },
  {
    id: 27,
    code: 'bj',
    name: '贝宁',
  },
  {
    id: 28,
    code: 'bl',
    name: '圣巴泰勒米岛',
  },
  {
    id: 29,
    code: 'bm',
    name: '百慕大',
  },
  {
    id: 30,
    code: 'bn',
    name: '文莱',
  },
  {
    id: 31,
    code: 'bo',
    name: '玻利维亚',
  },
  {
    id: 32,
    code: 'bq',
    name: '荷兰加勒比区',
  },
  {
    id: 33,
    code: 'br',
    name: '巴西',
  },
  {
    id: 34,
    code: 'bs',
    name: '巴哈马',
  },
  {
    id: 35,
    code: 'bt',
    name: '不丹',
  },
  {
    id: 36,
    code: 'bv',
    name: '布韦岛',
  },
  {
    id: 37,
    code: 'bw',
    name: '博茨瓦纳',
  },
  {
    id: 38,
    code: 'by',
    name: '白俄罗斯',
  },
  {
    id: 39,
    code: 'bz',
    name: '伯利兹',
  },
  {
    id: 40,
    code: 'ca',
    name: '加拿大',
  },
  {
    id: 41,
    code: 'cc',
    name: '科科斯群岛',
  },
  {
    id: 42,
    code: 'cf',
    name: '中非',
  },
  {
    id: 43,
    code: 'ch',
    name: '瑞士',
  },
  {
    id: 44,
    code: 'cl',
    name: '智利',
  },
  {
    id: 45,
    code: 'cm',
    name: '喀麦隆',
  },
  {
    id: 46,
    code: 'co',
    name: '哥伦比亚',
  },
  {
    id: 47,
    code: 'cr',
    name: '哥斯达黎加',
  },
  {
    id: 48,
    code: 'cu',
    name: '古巴',
  },
  {
    id: 49,
    code: 'cv',
    name: '佛得角',
  },
  {
    id: 50,
    code: 'cx',
    name: '圣诞岛',
  },
  {
    id: 51,
    code: 'cy',
    name: '塞浦路斯',
  },
  {
    id: 52,
    code: 'cz',
    name: '捷克',
  },
  {
    id: 53,
    code: 'de',
    name: '德国',
  },
  {
    id: 54,
    code: 'dj',
    name: '吉布提',
  },
  {
    id: 55,
    code: 'dk',
    name: '丹麦',
  },
  {
    id: 56,
    code: 'dm',
    name: '多米尼克',
  },
  {
    id: 57,
    code: 'do',
    name: '多米尼加',
  },
  {
    id: 58,
    code: 'dz',
    name: '阿尔及利亚',
  },
  {
    id: 59,
    code: 'ec',
    name: '厄瓜多尔',
  },
  {
    id: 60,
    code: 'ee',
    name: '爱沙尼亚',
  },
  {
    id: 61,
    code: 'eg',
    name: '埃及',
  },
  {
    id: 62,
    code: 'eh',
    name: '西撒哈拉',
  },
  {
    id: 63,
    code: 'er',
    name: '厄立特里亚',
  },
  {
    id: 64,
    code: 'es',
    name: '西班牙',
  },
  {
    id: 65,
    code: 'fi',
    name: '芬兰',
  },
  {
    id: 66,
    code: 'fj',
    name: '斐济群岛',
  },
  {
    id: 67,
    code: 'fm',
    name: '密克罗尼西亚联邦',
  },
  {
    id: 68,
    code: 'fo',
    name: '法罗群岛',
  },
  {
    id: 69,
    code: 'fr',
    name: '法国',
  },
  {
    id: 70,
    code: 'ga',
    name: '加蓬',
  },
  {
    id: 71,
    code: 'gd',
    name: '格林纳达',
  },
  {
    id: 72,
    code: 'ge',
    name: '格鲁吉亚',
  },
  {
    id: 73,
    code: 'gf',
    name: '法属圭亚那',
  },
  {
    id: 74,
    code: 'gh',
    name: '加纳',
  },
  {
    id: 75,
    code: 'gi',
    name: '直布罗陀',
  },
  {
    id: 76,
    code: 'gl',
    name: '格陵兰',
  },
  {
    id: 77,
    code: 'gn',
    name: '几内亚',
  },
  {
    id: 78,
    code: 'gp',
    name: '瓜德罗普',
  },
  {
    id: 79,
    code: 'gq',
    name: '赤道几内亚',
  },
  {
    id: 80,
    code: 'gr',
    name: '希腊',
  },
  {
    id: 81,
    code: 'gt',
    name: '危地马拉',
  },
  {
    id: 82,
    code: 'gu',
    name: '关岛',
  },
  {
    id: 83,
    code: 'gw',
    name: '几内亚比绍',
  },
  {
    id: 84,
    code: 'gy',
    name: '圭亚那',
  },
  {
    id: 85,
    code: 'hm',
    name: '赫德岛和麦克唐纳群岛',
  },
  {
    id: 86,
    code: 'hn',
    name: '洪都拉斯',
  },
  {
    id: 87,
    code: 'hr',
    name: '克罗地亚',
  },
  {
    id: 88,
    code: 'ht',
    name: '海地',
  },
  {
    id: 89,
    code: 'hu',
    name: '匈牙利',
  },
  {
    id: 90,
    code: 'id',
    name: '印尼',
  },
  {
    id: 91,
    code: 'ie',
    name: '爱尔兰',
  },
  {
    id: 92,
    code: 'il',
    name: '以色列',
  },
  {
    id: 93,
    code: 'im',
    name: '马恩岛',
  },
  {
    id: 94,
    code: 'in',
    name: '印度',
  },
  {
    id: 95,
    code: 'io',
    name: '英属印度洋领地',
  },
  {
    id: 96,
    code: 'iq',
    name: '伊拉克',
  },
  {
    id: 97,
    code: 'ir',
    name: '伊朗',
  },
  {
    id: 98,
    code: 'is',
    name: '冰岛',
  },
  {
    id: 99,
    code: 'it',
    name: '意大利',
  },
  {
    id: 100,
    code: 'je',
    name: '泽西岛',
  },
  {
    id: 101,
    code: 'jm',
    name: '牙买加',
  },
  {
    id: 102,
    code: 'jo',
    name: '约旦',
  },
  {
    id: 103,
    code: 'jp',
    name: '日本',
  },
  {
    id: 104,
    code: 'kh',
    name: '柬埔寨',
  },
  {
    id: 105,
    code: 'ki',
    name: '基里巴斯',
  },
  {
    id: 106,
    code: 'km',
    name: '科摩罗',
  },
  {
    id: 107,
    code: 'kw',
    name: '科威特',
  },
  {
    id: 108,
    code: 'ky',
    name: '开曼群岛',
  },
  {
    id: 109,
    code: 'lb',
    name: '黎巴嫩',
  },
  {
    id: 110,
    code: 'li',
    name: '列支敦士登',
  },
  {
    id: 111,
    code: 'lk',
    name: '斯里兰卡',
  },
  {
    id: 112,
    code: 'lr',
    name: '利比里亚',
  },
  {
    id: 113,
    code: 'ls',
    name: '莱索托',
  },
  {
    id: 114,
    code: 'lt',
    name: '立陶宛',
  },
  {
    id: 115,
    code: 'lu',
    name: '卢森堡',
  },
  {
    id: 116,
    code: 'lv',
    name: '拉脱维亚',
  },
  {
    id: 117,
    code: 'ly',
    name: '利比亚',
  },
  {
    id: 118,
    code: 'ma',
    name: '摩洛哥',
  },
  {
    id: 119,
    code: 'mc',
    name: '摩纳哥',
  },
  {
    id: 120,
    code: 'md',
    name: '摩尔多瓦',
  },
  {
    id: 121,
    code: 'me',
    name: '黑山',
  },
  {
    id: 122,
    code: 'mf',
    name: '法属圣马丁',
  },
  {
    id: 123,
    code: 'mg',
    name: '马达加斯加',
  },
  {
    id: 124,
    code: 'mh',
    name: '马绍尔群岛',
  },
  {
    id: 125,
    code: 'mk',
    name: '马其顿',
  },
  {
    id: 126,
    code: 'ml',
    name: '马里',
  },
  {
    id: 127,
    code: 'mm',
    name: '缅甸',
  },
  {
    id: 128,
    code: 'mo',
    name: '澳门',
  },
  {
    id: 129,
    code: 'mq',
    name: '马提尼克',
  },
  {
    id: 130,
    code: 'mr',
    name: '毛里塔尼亚',
  },
  {
    id: 131,
    code: 'ms',
    name: '蒙塞拉特岛',
  },
  {
    id: 132,
    code: 'mt',
    name: '马耳他',
  },
  {
    id: 133,
    code: 'mv',
    name: '马尔代夫',
  },
  {
    id: 134,
    code: 'mw',
    name: '马拉维',
  },
  {
    id: 135,
    code: 'mx',
    name: '墨西哥',
  },
  {
    id: 136,
    code: 'my',
    name: '马来西亚',
  },
  {
    id: 137,
    code: 'na',
    name: '纳米比亚',
  },
  {
    id: 138,
    code: 'ne',
    name: '尼日尔',
  },
  {
    id: 139,
    code: 'nf',
    name: '诺福克岛',
  },
  {
    id: 140,
    code: 'ng',
    name: '尼日利亚',
  },
  {
    id: 141,
    code: 'ni',
    name: '尼加拉瓜',
  },
  {
    id: 142,
    code: 'nl',
    name: '荷兰',
  },
  {
    id: 143,
    code: 'no',
    name: '挪威',
  },
  {
    id: 144,
    code: 'np',
    name: '尼泊尔',
  },
  {
    id: 145,
    code: 'nr',
    name: '瑙鲁',
  },
  {
    id: 146,
    code: 'om',
    name: '阿曼',
  },
  {
    id: 147,
    code: 'pa',
    name: '巴拿马',
  },
  {
    id: 148,
    code: 'pe',
    name: '秘鲁',
  },
  {
    id: 149,
    code: 'pf',
    name: '法属波利尼西亚',
  },
  {
    id: 150,
    code: 'pg',
    name: '巴布亚新几内亚',
  },
  {
    id: 151,
    code: 'ph',
    name: '菲律宾',
  },
  {
    id: 152,
    code: 'pk',
    name: '巴基斯坦',
  },
  {
    id: 153,
    code: 'pl',
    name: '波兰',
  },
  {
    id: 154,
    code: 'pn',
    name: '皮特凯恩群岛',
  },
  {
    id: 155,
    code: 'pr',
    name: '波多黎各',
  },
  {
    id: 156,
    code: 'ps',
    name: '巴勒斯坦',
  },
  {
    id: 157,
    code: 'pw',
    name: '帕劳',
  },
  {
    id: 158,
    code: 'py',
    name: '巴拉圭',
  },
  {
    id: 159,
    code: 'qa',
    name: '卡塔尔',
  },
  {
    id: 160,
    code: 're',
    name: '留尼汪',
  },
  {
    id: 161,
    code: 'ro',
    name: '罗马尼亚',
  },
  {
    id: 162,
    code: 'rs',
    name: '塞尔维亚',
  },
  {
    id: 163,
    code: 'ru',
    name: '俄罗斯',
  },
  {
    id: 164,
    code: 'rw',
    name: '卢旺达',
  },
  {
    id: 165,
    code: 'sb',
    name: '所罗门群岛',
  },
  {
    id: 166,
    code: 'sc',
    name: '塞舌尔',
  },
  {
    id: 167,
    code: 'sd',
    name: '苏丹',
  },
  {
    id: 168,
    code: 'se',
    name: '瑞典',
  },
  {
    id: 169,
    code: 'sg',
    name: '新加坡',
  },
  {
    id: 170,
    code: 'si',
    name: '斯洛文尼亚',
  },
  {
    id: 171,
    code: 'sk',
    name: '斯洛伐克',
  },
  {
    id: 172,
    code: 'sl',
    name: '塞拉利昂',
  },
  {
    id: 173,
    code: 'sm',
    name: '圣马力诺',
  },
  {
    id: 174,
    code: 'sn',
    name: '塞内加尔',
  },
  {
    id: 175,
    code: 'so',
    name: '索马里',
  },
  {
    id: 176,
    code: 'sr',
    name: '苏里南',
  },
  {
    id: 177,
    code: 'ss',
    name: '南苏丹',
  },
  {
    id: 178,
    code: 'st',
    name: '圣多美和普林西比',
  },
  {
    id: 179,
    code: 'sv',
    name: '萨尔瓦多',
  },
  {
    id: 180,
    code: 'sy',
    name: '叙利亚',
  },
  {
    id: 181,
    code: 'sz',
    name: '斯威士兰',
  },
  {
    id: 182,
    code: 'tc',
    name: '特克斯和凯科斯群岛',
  },
  {
    id: 183,
    code: 'td',
    name: '乍得',
  },
  {
    id: 184,
    code: 'tg',
    name: '多哥',
  },
  {
    id: 185,
    code: 'th',
    name: '泰国',
  },
  {
    id: 186,
    code: 'tk',
    name: '托克劳',
  },
  {
    id: 187,
    code: 'tl',
    name: '东帝汶',
  },
  {
    id: 188,
    code: 'tn',
    name: '突尼斯',
  },
  {
    id: 189,
    code: 'to',
    name: '汤加',
  },
  {
    id: 190,
    code: 'tr',
    name: '土耳其',
  },
  {
    id: 191,
    code: 'tv',
    name: '图瓦卢',
  },
  {
    id: 192,
    code: 'tz',
    name: '坦桑尼亚',
  },
  {
    id: 193,
    code: 'ua',
    name: '乌克兰',
  },
  {
    id: 194,
    code: 'ug',
    name: '乌干达',
  },
  {
    id: 195,
    code: 'uy',
    name: '乌拉圭',
  },
  {
    id: 196,
    code: 'va',
    name: '梵蒂冈',
  },
  {
    id: 197,
    code: 've',
    name: '委内瑞拉',
  },
  {
    id: 198,
    code: 'vg',
    name: '英属维尔京群岛',
  },
  {
    id: 199,
    code: 'vi',
    name: '美属维尔京群岛',
  },
  {
    id: 200,
    code: 'vn',
    name: '越南',
  },
  {
    id: 201,
    code: 'wf',
    name: '瓦利斯和富图纳',
  },
  {
    id: 202,
    code: 'ws',
    name: '萨摩亚',
  },
  {
    id: 203,
    code: 'ye',
    name: '也门',
  },
  {
    id: 204,
    code: 'yt',
    name: '马约特',
  },
  {
    id: 205,
    code: 'za',
    name: '南非',
  },
  {
    id: 206,
    code: 'zm',
    name: '赞比亚',
  },
  {
    id: 207,
    code: 'zw',
    name: '津巴布韦',
  },
  {
    id: 208,
    code: 'cn',
    name: '中国 内地',
  },
  {
    id: 209,
    code: 'cg',
    name: '刚果（布）',
  },
  {
    id: 210,
    code: 'cd',
    name: '刚果（金）',
  },
  {
    id: 211,
    code: 'mz',
    name: '莫桑比克',
  },
  {
    id: 212,
    code: 'gg',
    name: '根西岛',
  },
  {
    id: 213,
    code: 'gm',
    name: '冈比亚',
  },
  {
    id: 214,
    code: 'mp',
    name: '北马里亚纳群岛',
  },
  {
    id: 215,
    code: 'et',
    name: '埃塞俄比亚',
  },
  {
    id: 216,
    code: 'nc',
    name: '新喀里多尼亚',
  },
  {
    id: 217,
    code: 'vu',
    name: '瓦努阿图',
  },
  {
    id: 218,
    code: 'tf',
    name: '法属南部领地',
  },
  {
    id: 219,
    code: 'nu',
    name: '纽埃',
  },
  {
    id: 220,
    code: 'um',
    name: '美国本土外小岛屿',
  },
  {
    id: 221,
    code: 'ck',
    name: '库克群岛',
  },
  {
    id: 222,
    code: 'gb',
    name: '英国',
  },
  {
    id: 223,
    code: 'tt',
    name: '特立尼达和多巴哥',
  },
  {
    id: 224,
    code: 'vc',
    name: '圣文森特和格林纳丁斯',
  },
  {
    id: 225,
    code: 'tw',
    name: '中国台湾',
  },
  {
    id: 226,
    code: 'nz',
    name: '新西兰',
  },
  {
    id: 227,
    code: 'sa',
    name: '沙特阿拉伯',
  },
  {
    id: 228,
    code: 'la',
    name: '老挝',
  },
  {
    id: 229,
    code: 'kp',
    name: '朝鲜 北朝鲜',
  },
  {
    id: 230,
    code: 'kr',
    name: '韩国 南朝鲜',
  },
  {
    id: 231,
    code: 'pt',
    name: '葡萄牙',
  },
  {
    id: 232,
    code: 'kg',
    name: '吉尔吉斯斯坦',
  },
  {
    id: 233,
    code: 'kz',
    name: '哈萨克斯坦',
  },
  {
    id: 234,
    code: 'tj',
    name: '塔吉克斯坦',
  },
  {
    id: 235,
    code: 'tm',
    name: '土库曼斯坦',
  },
  {
    id: 236,
    code: 'uz',
    name: '乌兹别克斯坦',
  },
  {
    id: 237,
    code: 'kn',
    name: '圣基茨和尼维斯',
  },
  {
    id: 238,
    code: 'pm',
    name: '圣皮埃尔和密克隆',
  },
  {
    id: 239,
    code: 'sh',
    name: '圣赫勒拿',
  },
  {
    id: 240,
    code: 'lc',
    name: '圣卢西亚',
  },
  {
    id: 241,
    code: 'mu',
    name: '毛里求斯',
  },
  {
    id: 242,
    code: 'ci',
    name: '科特迪瓦',
  },
  {
    id: 243,
    code: 'ke',
    name: '肯尼亚',
  },
  {
    id: 244,
    code: 'mn',
    name: '蒙古国',
  },
];
class HomeController extends Controller {
  async index() {
    const { ctx } = this;
    ctx.body = 'hi, egg';
  }
  async region() {
    this.ctx.body = {
      code: 200,
      message: 'success',
      result: regions,
    };
  }
  async submit() {
    const res = await this.ctx.service.home.submit_v2(this.ctx.request.body);
    this.ctx.body = {
      code: 200,
      message: 'success',
      result: res,
    };
  }
  async submit_v2() {
    const res = await this.ctx.service.home.submit(this.ctx.request.body);
    this.ctx.body = {
      code: 200,
      message: 'success',
      result: res,
    };
  }
  async getWjxParams() {
    const res = await this.ctx.service.home.getWjxParams(
      this.ctx.query.sendUrl,
      this.ctx.query.region
    );
    this.ctx.body = {
      code: 200,
      message: 'success',
      result: res,
    };
  }
  async getWjwParams() {
    const res = await this.ctx.service.home.getWjwparams(
      this.ctx.query.sendUrl,
      this.ctx.query.region
    );
    this.ctx.body = {
      code: 200,
      message: 'success',
      result: res,
    };
  }
}

module.exports = HomeController;
